#ifndef __VECTOR4_H__
#define __VECTOR4_H__

#pragma once

#include "Vector3.h"

namespace Nezha
{

	class NEZHA_ENGINE_ENTRY Vector4
	{
	public:
		Vector4(){}

		Vector4(Real fX, Real fY, Real fZ, Real fW)
			:x(fX), y(fY), z(fZ), w(fW)
		{
		}

		Vector4(const Vector3 &pt, Real fW)
			:x(pt.x), y(pt.y), z(pt.z), w(fW)
		{
		}

		void set(const Vector3 &pt, Real fW = 0.0)
		{
			x = pt.x;
			y = pt.y;
			z = pt.z;
			w = fW;
		}

		void set(float _x, float _y, float _z, float _w)
		{
			x = _x;
			y = _y;
			z = _z;
			w = _w;
		}

		Real operator[](int i) const
		{
			const Real *p = &x;
			return (Real&) p[i];
		}

		Vector4 operator- () const
		{
			return (*this) * -1;
		}

		Vector4 operator+ (const Vector4 &pt) const
		{
			return Vector4(x+pt.x, y+pt.y,
				z+pt.z, w+pt.w);
		}

		Vector4 operator- (const Vector4 &pt) const
		{
			return Vector4(x-pt.x, y-pt.y,
				z-pt.z, w-pt.w);
		}

		Vector4 operator* (Real scalar) const
		{
			return Vector4(x*scalar, y*scalar,
				z*scalar, w*scalar);
		}

		Vector4 operator/ (Real scalar) const
		{
			return Vector4(x/scalar, y/scalar,
				z/scalar, w/scalar);
		}

		Vector4& operator+= (const Vector4 &pt)
		{
			x += pt.x;
			y += pt.y;
			z += pt.z;
			w += pt.w;
			return *this;
		}

		Vector4& operator-= (const Vector4 &pt)
		{
			x -= pt.x;
			y -= pt.y;
			z -= pt.z;
			w -= pt.w;
			return *this;
		}

		Vector4& operator*= (Real scalar)
		{
			x *= scalar;
			y *= scalar;
			z *= scalar;
			w *= scalar;
			return *this;
		}

		Vector4& operator/= (Real scalar)
		{
			x /= scalar;
			y /= scalar;
			z /= scalar;
			w /= scalar;
			return *this;
		}

		bool operator== (const Vector4 &pt) const
		{
			return x == pt.x && y == pt.y
				&& z == pt.z && w == pt.w;
		}

		bool operator!= (const Vector4 &pt) const
		{
			return !((*this) == pt);
		}

		Real x, y, z, w;

		static const Vector4 ZERO;
	};

}//end namespace Nezha


#endif //end __VECTOR4_H__